﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace DetectSandbox.DetectorPart
{
    [ToolboxItemAttribute(false)]
    public class DetectorPart : WebPart
    {
        protected override void RenderContents(HtmlTextWriter writer)
        {
            try
            {
                string ad = System.AppDomain.CurrentDomain.FriendlyName;
                writer.Write("<p>" + ad + "</p>");

                if (ad.Equals("Sandboxed Code Execution Partially Trusted Asp.net AppDomain"))
                    writer.Write("<p>Sandboxed Solution</p>");
                else
                    writer.Write("<p>Farm Solution</p>");
            }
            catch (Exception x)
            {
                writer.Write("<p>" + x.Message + "</p>");
            }
        }
    }
}
